<?php

namespace app\admin\model\user;

use think\Model;


class Destroy extends Model
{

    

    

    // 表名
    protected $name = 'user_destroy';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'prevtime_text',
        'logintime_text',
        'jointime_text',
        'status_text',
        'is_captain_text',
        'is_authentication_text',
        'is_merchant_text',
        'is_store_text',
        'is_employee_text'
    ];
    

    
    public function getStatusList()
    {
        return ['30' => __('Status 30')];
    }

    public function getIsCaptainList()
    {
        return ['0' => __('Is_captain 0'), '1' => __('Is_captain 1')];
    }

    public function getIsAuthenticationList()
    {
        return ['0' => __('Is_authentication 0'), '1' => __('Is_authentication 1')];
    }

    public function getIsMerchantList()
    {
        return ['0' => __('Is_merchant 0'), '1' => __('Is_merchant 1')];
    }

    public function getIsStoreList()
    {
        return ['1' => __('Is_store 1'), '0' => __('Is_store 0')];
    }

    public function getIsEmployeeList()
    {
        return ['0' => __('Is_employee 0'), '1' => __('Is_employee 1')];
    }


    public function getPrevtimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['prevtime']) ? $data['prevtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getLogintimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getJointimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['jointime']) ? $data['jointime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsCaptainTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_captain']) ? $data['is_captain'] : '');
        $list = $this->getIsCaptainList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsAuthenticationTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_authentication']) ? $data['is_authentication'] : '');
        $list = $this->getIsAuthenticationList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsMerchantTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_merchant']) ? $data['is_merchant'] : '');
        $list = $this->getIsMerchantList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsStoreTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_store']) ? $data['is_store'] : '');
        $list = $this->getIsStoreList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsEmployeeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_employee']) ? $data['is_employee'] : '');
        $list = $this->getIsEmployeeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function setPrevtimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setLogintimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setJointimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
